{include file="public/header" /}
<style>
    video{
        height: 100%!important;
        width: 100%!important;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">

            </div>
            <div class="hr-line-dashed"></div>
            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="testReload"></table>
                    <!--状态显示模板-->
                    <script type="text/html" id="imgTpl">
                        <ul class="aaasss">
                            {{#  layui.each(d.imgs, function(index, item){ }}
                            <img src="{{item}}" data-original="{{item}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                            {{#  }); }}
                        </ul>
                    </script>
                    <script type="text/html" id="imgTpl2">
                        <ul class="aaasss">
                            {{#  layui.each(d.oi_other_image, function(index, item){ }}
                            <img src="{{item}}" data-original="{{item}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                            {{#  }); }}
                        </ul>
                    </script>
                    <script type="text/html" id="viTpl">
                        {{# if(d.oi_other_video){ }}
                        <div style="width: 100%;height:50px">
                            <video controls="controls" >
                                <source src="{{d.oi_other_video}}" type="video/mp4" />
                            </video>
                        </div>
                        {{# } else{ }}
                        -
                        {{# } }}
                    </script>
                    <script type="text/html" id="oi_wx_report_url">
                        {{# if(d.oi_wx_report_url){ }}
                        <a href="{{d.oi_wx_report_url}}" style="color: dodgerblue">点击查看</a>
                        {{# } else{ }}
                        -
                        {{# } }}
                    </script>
                    <script type="text/html" id="opeBar">
                        <!-- -->
                        <a href="javascript:;" onclick="wk.layer_show('上传/编辑报告','{:url('orderSonPdf')}?oi_id={{d.oi_id}}','800','500')" class="btn btn-primary btn-xs m-r-xs" title="上传/编辑报告">上传/编辑</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("Order/orderDevice")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , where: {'order_id':{$order_id}}
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
               {type:'numbers', width: 80, title: '序号'}
                ,{field: 'xlname', width: '', title: '设备系列', align: 'center'}
                , {field: 'xhname', width:'', title: '设备型号', align: 'center'}
                , {field: 'gz_name', width:'', title: '故障', align: 'center'}
                , {field: 'oi_xulie', width:'', title: '序列表', align: 'center'}
                , {field: 'oi_desc', width:'', title: '故障描述', align: 'center'}
                , {field: 'imgs', width:'', title: '设备图片', align: 'center', toolbar: '#imgTpl'}
                , {field: 'oi_other_image', width:'', title: '其他图片', align: 'center', toolbar: '#imgTpl2'}
                , {field: 'oi_other_video', width:'200', title: '其他视频', align: 'center', toolbar: '#viTpl'}
                , {field: 'oi_wx_report_url', width:'', title: '报告', align: 'center', toolbar: '#oi_wx_report_url'}
                , {field: 'oi_wx_report_remark', width:'', title: '报告备注', align: 'center'}
                , {fixed: 'right', width:'100', title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
            , done: function (res, curr, count) {
                $('.aaasss').viewer({
                    url: 'data-original'
                });
            }
        });
        //监听单元格编辑
        table.on('edit(testReload)', function(obj){
            var value = obj.value //得到修改后的值
                    ,data = obj.data //得到所在行所有键值
                    ,field = obj.field; //得到字段
            // layer.msg('[ID: '+ data.id +'] ' + field + ' 字段更改为：'+ value);
            var patrn = /^[0-9]*$/;
            if(!patrn.test(value)){
                layer.msg('排序值只能为数字',{icon:2,time:1500,shade: 0.1},function(){
                    //重载当前页表格
                    $(".layui-laypage-btn").click();
                });
                return false;
            }
            wk.changeSort(data.banner_id,"{:url('sort')}",field,value);
        });
        //批量操作
        var $ = layui.$, active = {
            //批量删除
            batchDel:function () {
                wk.batchDel(getIds(),"{:url('del')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['s_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>